package com.thero.core.command.cmd;

import com.thero.core.command.Command;
import com.thero.core.net.ProtocolMessage;

/**
 * Created by wusk on 2017/12/1.
 * 吃子指令
 */
public class KillPiece extends Command {
    private int roomId;
    private int playerId;
    private short location;

    public KillPiece(ProtocolMessage message) throws Exception {
        super(message.getHeader());
        byte[] bytes = message.getMessage();
        if(bytes.length != 10){
            throw new Exception("Invalid message body. wrong message body length.");
        }
        this.roomId = readInt(bytes[0], bytes[1], bytes[2], bytes[3]);
        this.playerId = readInt(bytes[4], bytes[5], bytes[6], bytes[7]);
        this.location = readShort(bytes[8], bytes[9]);
        if(!checkLocation(location)){
            throw  new Exception("Operate point location is invalid.");
        }
    }

    public int getRoomId(){
        return this.roomId;
    }

    public int getPlayerId(){
        return this.playerId;
    }

    public short getLocation(){
        return this.location;
    }
}
